package com.rd.student.jiaji.class1.jinhongyu._0724;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test {
    private static final int CORE_POLL_SIZE = 5;
    private static final int MAX_POLL_SIZE = 10;
    private static final int QUEUE_CAPACITY = 20;
    private static final long KEEP_ALIVE_TIME = 1L;

    public static void main(String[] args) {
        ThreadPoolExecutor a =
                new ThreadPoolExecutor(
                        CORE_POLL_SIZE,
                        MAX_POLL_SIZE,
                        KEEP_ALIVE_TIME,
                        TimeUnit.SECONDS,
                        new ArrayBlockingQueue<>(QUEUE_CAPACITY),
                        new ThreadPoolExecutor.DiscardPolicy()
                        );

        for (int i = 0; i < 5; i++) {
            MyRunnable runnable = new MyRunnable();
            a.execute(runnable);
        }

        a.shutdown();
        System.out.println("finished");

    }

}
